﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using djpp.DomainModel;

namespace djpp.DomainModel
{
    public class ProjectRepo
    {
        public ProjectRepo()
        {
            _count = 0;
            _projects = new List<Project>();
            _commands = new List<ICommand>();
            _commands.Add(new CreateProjectCommand(this));
        }

        public void add(Project project)
        {
            foreach (var prj in _projects)
            {
                if (prj.Name.Equals(project.Name))
                    throw new ApplicationException();
            }
            _projects.Add(project);
            _count++;
        }

        public int Count    
        {
            get { return _count; }
        }

        public Project[] Projects
        {
            get { return _projects.ToArray(); }
        }

        public ICommand[] Commands
        {
            get { return _commands.ToArray(); }
        }

        private List<Project> _projects;
        private int _count;
        private List<ICommand> _commands;
    }
}
